﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Example05.aspx.cs" Inherits="Chapter36.Example05" %>

<!DOCTYPE html>

<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>代码清单 36-5 使用 arcTo 方法</title>
    <meta name="author" content="Adam Freeman" />
    <meta name="description" content="A simple example" />
    <link rel="shortcut icon" type="image/x-icon" href="favicon.ico" />
    <style>
        canvas {
            border: thin solid black;
        }

        body > * {
            float: left;
        }
    </style>
</head>
<body>
    <canvas id="canvas" width="500" height="140">Your browser doesn't support the <code>canvas</code> element.</canvas>
    <script>
        var ctx = document.getElementById('canvas').getContext('2d');

        var point1 = [100, 10];
        var point2 = [200, 10];
        var point3 = [200, 110];

        ctx.fillStyle = 'yellow';
        ctx.strokeStyle = 'black';
        ctx.lineWidth = 4;

        ctx.beginPath();
        ctx.moveTo(point1[0], point1[1]);
        ctx.arcTo(point2[0], point2[1], point3[0], point3[1], 100);
        ctx.stroke();

        drawPoint(point1[0], point1[1]);
        drawPoint(point2[0], point2[1]);
        drawPoint(point3[0], point3[1]);

        ctx.beginPath();
        ctx.moveTo(point1[0], point1[1]);
        ctx.lineTo(point2[0], point2[1]);
        ctx.lineTo(point3[0], point3[1]);
        ctx.stroke();

        function drawPoint(x, y) {
            ctx.lineWidth = 1;
            ctx.strokeStyle = 'red';
            ctx.strokeRect(x - 2, y - 2, 4, 4);
        }
    </script>
</body>
</html>
